
#ifndef SESSION_H_
#define SESSION_H_

#include "public.h"
using boost::asio::ip::tcp;
using namespace std;
using namespace Image::protobuf;

class session
    : public std::enable_shared_from_this<session>
{
public:
    session(tcp::socket socket)
        : socket_(std::move(socket))
    {
       

        totalReadeLen = 0;
    }

    void start();

private:
    

    uint32_t totalReadeLen;

    int ucharToMat(const uint8_t *p2, cv::Mat &src, int flag);
    ImageInfo imageBuff;

    void do_read();

    uint8_t *do_getdata(std::size_t length);

    tcp::socket socket_;
    enum
    {
        //    max_length = 65535
        max_length = (1024 * 1024 * 3 + 4) * sizeof(uint32_t)
    };
    char data_[max_length];
};

#endif